From f93729dfae8b2328d0fde2d570f04fae825714ef Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 21 Jun 2004 06:13:50 +0000 Subject: [PATCH] bitkeeper revision 1.989 (40d67c9em66pd7yVqnpYax0LoJ-lzw) Bug fixes. --- xen/common/dom0_ops.c | 63 ++++++++++++++++++++++++------------------- xen/common/schedule.c | 15 ++++++----- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index ea298eeac5..515ff4d2b8 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -103,9 +103,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op) ret = -ESRCH; if ( d != NULL ) { - domain_stop(d); + ret = -EINVAL; + if ( d != current ) + { + domain_stop(d); + ret = 0; + } put_domain(d); - ret = 0; } } break; @@ -173,9 +177,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op) if ( d != current ) { domain_kill(d); - put_domain(d); ret = 0; } + put_domain(d); } } break; @@ -183,34 +187,35 @@ long do_dom0_op(dom0_op_t *u_dom0_op) case DOM0_PINCPUDOMAIN: { domid_t dom = op->u.pincpudomain.domain; + struct domain *d = find_domain_by_id(dom); + int cpu = op->u.pincpudomain.cpu; + + if ( d == NULL ) + { + ret = -ESRCH; + break; + } - if ( dom == current->domain || dom == IDLE_DOMAIN_ID ) + if ( d == current ) + { ret = -EINVAL; + put_domain(d); + break; + } + + if ( cpu == -1 ) + { + clear_bit(DF_CPUPINNED, &d->flags); + } else { - struct domain *d = find_domain_by_id(dom); - int cpu = op->u.pincpudomain.cpu; - - ret = -ESRCH; - - if ( d != NULL ) - { - if ( cpu == -1 ) - { - clear_bit(DF_CPUPINNED, &d->flags); - } - else - { - domain_pause(d); - set_bit(DF_CPUPINNED, &d->flags); - cpu = cpu % smp_num_cpus; - d->processor = cpu; - domain_unpause(d); - } - put_domain(d); - ret = 0; - } + domain_pause(d); + set_bit(DF_CPUPINNED, &d->flags); + d->processor = cpu % smp_num_cpus; + domain_unpause(d); } + + put_domain(d); } break; @@ -293,7 +298,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op) op->u.getdomaininfo.flags = (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0); - domain_pause(d); + if ( d != current ) + domain_pause(d); op->u.getdomaininfo.domain = d->domain; strcpy(op->u.getdomaininfo.name, d->name); @@ -381,7 +387,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op) ret = -EINVAL; gdi_out: - domain_unpause(d); + if ( d != current ) + domain_unpause(d); put_domain(d); } break; diff --git a/xen/common/schedule.c b/xen/common/schedule.c index cfae3bfedc..d9cb33fdb5 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -178,16 +178,17 @@ void domain_sleep(struct domain *d) int cpu = d->processor; spin_lock_irqsave(&schedule_lock[cpu], flags); - - if ( test_bit(DF_RUNNING, &d->flags) ) - cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); - else if ( __task_on_runqueue(d) ) - __del_from_runqueue(d); - + if ( likely(!domain_runnable(d)) ) + { + if ( test_bit(DF_RUNNING, &d->flags) ) + cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); + else if ( __task_on_runqueue(d) ) + __del_from_runqueue(d); + } spin_unlock_irqrestore(&schedule_lock[cpu], flags); /* Synchronous. */ - while ( test_bit(DF_RUNNING, &d->flags) ) + while ( test_bit(DF_RUNNING, &d->flags) && !domain_runnable(d) ) { smp_mb(); cpu_relax(); -- 2.30.2